package cn.hm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.Queue;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/7/31 10:53
 */

@RestController
@RequestMapping("/msg")
public class SendMsgController {

    @Autowired
    private JmsTemplate jmsTemplate;
    @Autowired
    private Queue queue;

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;


    @RequestMapping("/send")
    public String send(String msg) {
        jmsMessagingTemplate.convertAndSend(queue, msg);

        return "queue消息发送成功success" + Thread.currentThread().getName();
    }

}
